import 'package:cloud_medicine/pages/message_discuss_list.dart';
import 'package:cloud_medicine/pages/notice_message_list.dart';
import 'package:cloud_medicine/pages/post_message_list.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MessageListPage extends StatefulWidget {
  @override
  _MessageListPageState createState() => _MessageListPageState();
}

class _MessageListPageState extends State<MessageListPage>
    with SingleTickerProviderStateMixin {
  TabController tabcontroller; //Tab页的控制器，可以用来定义Tab标签和内容页的坐标

  @override
  void initState() {
    super.initState();
    tabcontroller = new TabController(
      length: 3, //Tab页的个数
      vsync: this, //动画效果的异步处理，默认格式
      initialIndex: 0,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('消息中心'),
        centerTitle: true,
        bottom: TabBar(
          indicatorSize: TabBarIndicatorSize.label,
          controller: tabcontroller,
          tabs: <Widget>[
            Tab(text: '通知消息'),
            Tab(text: '帖子消息'),
            Tab(text: '会诊消息'),
          ],
        ),
      ),
      body: TabBarView(
        controller: tabcontroller,
        children: <Widget>[
          NoticeMessageListPage(),
          PostMessageListPage(),
          MessageDisCussListPage(),
        ],
      ),
    );
  }
}
